package cn.peach.hrm.feign.client;

import cn.peach.hrm.doc.CourseDoc;
import cn.peach.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author you
 * @create 2021/11/28 16:23
 */
@Component
@Slf4j
public class CourseESFeignClientFallbackFactory implements FallbackFactory<CourseESFeignClient> {
    @Override
    public CourseESFeignClient create(Throwable throwable) {
        return new CourseESFeignClient() {
            @Override
            public AjaxResult save(CourseDoc courseDoc) {
                log.error("服务降级 {}", throwable.getMessage());
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("系统错误");
            }
        };
    }
}
